<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/

get_config_keytable("book");
empty($do) && $do = 'list';
if ($do == 'list') {
	include_once('template/add.php');

} elseif ($do == 'save') {
	$savetype = getGP('savetype','P');
	$booktype = getGP('booktype','P');
	$bookumber=getGP('bookumber','P');
	$bookname=getGP('bookname','P');
	$author=getGP('author','P');
	$publishing=getGP('publishing','P');
	$appendix=getGP('appendix','P');
	$booknum=getGP('booknum','P');
	$content=getGP('content','P');
	$book = array(
		'booktype' => $booktype,
		'bookumber' => $bookumber,
		'bookname' => $bookname,
		'author' => $author,
		'publishing' => $publishing,
		'appendix' => $appendix,
		'booknum' => $booknum,
		'content' => $content,
		'type' => '0',
		'date' => get_date('Y-m-d H:i:s',PHP_TIME),
		'uid' => $_USER->id
	);
	insert_db('book',$book);
	$id=$db->insert_id();
	$content=$booktype.get_inc_log(1).$bookumber.get_inc_log(1).$bookname.get_inc_log(1).$author.get_inc_log(1).$publishing.get_inc_log(1).$appendix.get_inc_log(1).$booknum.get_inc_log(1).$content;
	$title='新增图书信息';
	get_oa_log_dbadd($id,$content,$title,22,$_USER->id);
    goto_page('admin.php?ac=index&fileurl=book');

}

//读取部门
function GET_FILE_PUBLIC_LIST($fatherid=0,$selid=0,$layer=0)
{


	$str=""; 
    global $db;
	$query = $db->query("SELECT * FROM ".DB_TABLEPRE."book_type where father='$fatherid' ORDER BY id Asc  ");
	
	if(count($query)>0){
	   for($i=0;$i<$layer;$i++){
	   
	   $str.="├";
	   
	   }
	while ($row = $db->fetch_array($query)) {
	$selstr = $row['id'] == $selid ? 'selected="selected"' : '';
	
	$htmlstr= '<option value="'.$row['id'].'"  '.$selstr.'>'.$str.$row['title'].'</option>';
	
	echo $htmlstr;

	GET_FILE_PUBLIC_LIST($row['id'],$selid,$layer+1,$type);
	
	}

	}
	
   return ;

}

?>